class ContractItemsController < ApplicationController
  before_action :set_contract_item, only: [:show, :edit, :update, :destroy]

  respond_to :html

  def index
    @contract_items = ContractItem.all
    respond_with(@contract_items)
  end

  def show
    respond_with(@contract_item)
  end

  def new
    @contract_item = ContractItem.new
    respond_with(@contract_item)
  end

  def edit
  end

  def create
    @contract_item = ContractItem.new(contract_item_params)
    @contract_item.save
    respond_with(@contract_item)
  end

  def update
    @contract_item.update(contract_item_params)
    respond_with(@contract_item)
  end

  def destroy
    @contract_item.destroy
    respond_with(@contract_item)
  end

  private
    def set_contract_item
      @contract_item = ContractItem.find(params[:id])
    end

    def contract_item_params
      params.require(:contract_item).permit(:product_name, :product_desc, :unit, :quantity, :unit_price, :tax_rate, :amount, :comment)
    end
end
